package com.platform.mobile.operator;

import java.util.LinkedHashMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.platform.base.SysException;
import com.platform.mobile.bean.GetNoticeRequest;
import com.platform.mobile.bean.GetNoticeResponse;
import com.platform.mobile.bean.ReqBean;
import com.platform.mobile.bean.ResBean;
import com.platform.mobile.bean.ResultBean;
import com.platform.mobile.factory.Operator;
import com.platform.mobile.service.MainPageService;

@Component
public class GetNotice extends Operator{
	
	private static Logger log = LoggerFactory.getLogger(GetNotice.class);
	
	@Autowired
	private MainPageService service;

	@Override
	public ResBean operate(ReqBean reqBean) throws SysException {
		
		log.info("进入到GetNotice业务处理类，处理[" + reqBean.getClientInfo() + "]用户请求");
		ResBean resBean = new ResBean();
		resBean.setClientInfo(reqBean.getClientInfo());
		resBean.setJsonrpc("2.0");
		resBean.setMethod("GetNotice");
		ResultBean result = new ResultBean();
		
		GetNoticeRequest request = new GetNoticeRequest();
		GetNoticeResponse response = new GetNoticeResponse();
		
		try{
			Object params = reqBean.getParams();
			if(params != null){
				
				@SuppressWarnings("unchecked")
				LinkedHashMap<String, Object> paramMap = (LinkedHashMap<String, Object>)params;
				request.setOrg_id(paramMap.get("org_id").toString());
				
				response = service.getVisitNoticeByOrgId(request.getOrg_id());

				result.setResultStatus("1");
				result.setInfo("业务处理成功");
				result.setData(response);
			} else {
				result.setResultStatus("0");
				result.setInfo("业务处理失败：（请求参数传入有误）");
				result.setData(response);
			}
			
			resBean.setResult(result);
		}catch(Exception e){
			result.setResultStatus("0");
			result.setInfo("服务端处理异常，业务处理失败");
			result.setData(response);
			resBean.setResult(result);
		}

		return resBean;
	}

}
